package com.ztesoft.web.backup;



import java.io.File;
import java.io.FileInputStream;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.Callable;

import com.ztesoft.core.spring.context.SpringApplicationContextHolder;
import com.ztesoft.framework.log.ZTEsoftLogManager;
import com.ztesoft.framework.util.DateUtils;
import com.ztesoft.framework.util.StringUtils;
import com.ztesoft.web.common.Configuration;
import com.ztesoft.web.common.DMSConstant;
import com.ztesoft.web.common.SeforgeFtpUtils;
import com.ztesoft.web.common.Util;
import com.ztesoft.web.common.vo.HostConnInfoVO;
import com.ztesoft.web.common.vo.HostConnMethodVO;
import com.ztesoft.web.common.vo.HostInfoPOJO;
import com.ztesoft.web.common.vo.TaskNotify;
import com.ztesoft.web.filecommon.customdb.dao.DmFCustomDao;
import com.ztesoft.web.filecommon.db.po.DmFDetailPO;
import com.ztesoft.web.filecommon.db.po.DmFPO;
import com.ztesoft.web.syncbaseinfo.service.BaseInfoService;
import com.ztesoft.web.taskgenerator.db.arg.DmTaskStageArg;
import com.ztesoft.web.taskgenerator.db.arg.DmTaskStageArg.DmTaskStageCriteria;
import com.ztesoft.web.taskgenerator.db.dao.DmTaskStageDao;
import com.ztesoft.web.taskgenerator.db.po.DmTaskStagePO;

/**
 * 备份处理线程
 * Created by Chen.Shitian on 2015/8/1.
 */
/**
 * @author asus
 *
 */
public class BackUpTask implements Callable<String>{
	private static final ZTEsoftLogManager LOGGER = ZTEsoftLogManager.getLogger(BackUpTask.class);
	private DmFCustomDao dmfCustomDao;
	private DmTaskStageDao dmTaskStageDao;
	private BaseInfoService baseInfoService;
	private DmTaskStagePO dtsPO;
	private DmTaskStagePO checkStagoPO;
	private DmTaskStagePO cleanStagoPO;
	private Integer buCount;
	private Integer strategyId;
	
    public BackUpTask(DmTaskStagePO taskStagepo,int backCount){
    	dtsPO = taskStagepo;
    	buCount = backCount;
    	dmfCustomDao =  SpringApplicationContextHolder.getBean(DmFCustomDao.class);
    	dmTaskStageDao =  SpringApplicationContextHolder.getBean(DmTaskStageDao.class);
    	baseInfoService =  SpringApplicationContextHolder.getBean(BaseInfoService.class);
    	strategyId = taskStagepo.getDmStrategyId();
    }
 
	@Override
	public String call()  {
		System.out.println("任务调度|++===备份服务|任务ID={0},策略ID={1},备份对象={2}BEGIN..");
		LOGGER.info("任务调度|++===备份服务|任务ID={0},策略ID={1},备份对象={2}BEGIN..]",
				dtsPO.getDmTaskId(),dtsPO.getDmStrategyId(),dtsPO.getCheckObjName());
		String backUpState = DMSConstant.Status.SUCCESS.toString();
		//1.获取体检,清理任务环节记录
		LOGGER.info("1.获取体检,清理任务环节记录");
		DmTaskStageArg arg = new DmTaskStageArg();
		DmTaskStageCriteria c = arg.createCriteria();
		c.andDmTaskIdEqualTo(dtsPO.getDmTaskId());
		c.andDmStrategyIdEqualTo(strategyId);
		c.andCheckObjNameEqualTo(dtsPO.getCheckObjName());
		List<DmTaskStagePO> stageList= dmTaskStageDao.selectByArg(arg);
		for (DmTaskStagePO dmTaskStagePO : stageList) {
			if(DMSConstant.STAGE_CHECKUP == dmTaskStagePO.getStage()){
				checkStagoPO = dmTaskStagePO;
			}else if(DMSConstant.STAGE_CLEANUP == dmTaskStagePO.getStage()){
				cleanStagoPO = dmTaskStagePO;
			}
		}
		try{
			//2.更新任务环节表的开始时间
			LOGGER.info("2.更新任务环节表的开始时间");
			dmTaskStageDao.updateStateAndStartTimeByPrimaryKey(dtsPO.getDmInfoId());
			//3.获取文件脚本操作轨迹记录
			LOGGER.info("获取文件脚本操作轨迹记录");
			List <DmFPO> dmFList = dmfCustomDao.selectByInfoId(checkStagoPO.getDmInfoId(),strategyId);
			for (DmFPO dmFPO : dmFList) {
				if(DMSConstant.Status.SUCCESS.toString().equals(backUpState)){
					//4.对文件进行打包,压缩,移到目标地址
					LOGGER.info("对文件进行打包,压缩,移到目标地址dmFPO.trackId:"+dmFPO.getTrackId());
					try{
						backUpState = this.dealFile(dmFPO);
					}catch(Exception e){
						backUpState = DMSConstant.Status.FALSE.toString();
						LOGGER.error("任务调度|++===备份服务|dmFPO.trackId={0}备份失败..{1}]",
								dmFPO.getTrackId(),e.getMessage());
						dmfCustomDao.updateDetailStateByTrackId(strategyId,dmFPO.getTrackId(),DMSConstant.Status.BACKUPFALSE.toString());
						this.updateTaskStageState(backUpState);
					}
				}
			}
			//5.更新备份任务环节表状态
			LOGGER.info("更新备份任务环节表状态:"+backUpState);
			this.updateTaskStageState(backUpState);
			
		}catch(Exception e){
			backUpState = DMSConstant.Status.FALSE.toString();
			LOGGER.error("任务调度|++===备份服务|任务ID={0},策略ID={1},备份对象={2}备份失败..{3}]",
					dtsPO.getDmTaskId(),dtsPO.getDmStrategyId(),dtsPO.getCheckObjName(),e.getMessage());
			this.updateTaskStageState(backUpState);
		}
		return backUpState;
	}


	/**
	 * 4.对文件进行打包,压缩,移到目标地址，更新轨迹吧记录
	 * @param dmFPO
	 * @return
	 */
	private String dealFile(DmFPO dmFPO){
		String backUpState = DMSConstant.Status.SUCCESS.toString();
		//1.打包
		LOGGER.info("4.1打包");
		Map<String,Object> map = this.packingFile(dmFPO);
		String filename = map.get("fileName").toString();
		if(!(Boolean) map.get("result")){
			this.updateData(map.get("state").toString(),dmFPO,filename);
			return map.get("state").toString();
		}
		LOGGER.info("4.1打包结果："+(Boolean) map.get("result"));
		//2.压缩
		LOGGER.info("4.2压缩");
		map = this.compressionFile(dmFPO,filename);
		filename = map.get("fileName").toString();
		if(!(Boolean) map.get("result")){
			this.updateData(DMSConstant.Status.FALSE.toString(),dmFPO,filename);
			return DMSConstant.Status.FALSE.toString();
		}
		LOGGER.info("4.2压缩结果："+(Boolean) map.get("result"));
		//3.移到目标
		LOGGER.info("4.3移到目标");
		map = this.moveFile(dmFPO,filename);
		if(!(Boolean) map.get("result")){
			this.updateData(DMSConstant.Status.FALSE.toString(),dmFPO,filename);
			return map.get("state").toString();
		}
		LOGGER.info("4.3移到目标结果："+(Boolean) map.get("result"));
		//4.更新数据
		LOGGER.info("4.4更新数据");
		this.updateData(backUpState,dmFPO,filename);
		return backUpState;
	}
	
	/**
	 * 4-1.对文件进行打包
	 * @param dmFPO
	 * @return
	 */
	private Map<String,Object> packingFile(DmFPO dmFPO){
		Map<String,Object> resultMap = new HashMap<String, Object>();
		boolean continueFalge = true;
		int time = 0;
		String packageName = dmFPO.getPackageName();
		//Map<DmFDetailPO,String> commandMap = new HashMap<DmFDetailPO,String>();
		Map<DmFDetailPO,String> commandMap = new LinkedHashMap<DmFDetailPO, String>();
		while(continueFalge){
			time++;
			//根据批量处理数获取要打包的文件记录
			List<DmFDetailPO> dmfdetails = dmfCustomDao.selectByTrackId(dmFPO.getTrackId(), strategyId,buCount,DMSConstant.Status.TOBACKUP.toString());
			LOGGER.info("根据批量处理数获取要打包的文件记录，处理条数："+dmfdetails.size());
			if(dmfdetails.size()>0){
				LOGGER.info("检测是否有异常");
				String state = this.isNormal();
				LOGGER.info("检测结果:"+state);
				if(StringUtils.isNotEmpty(state)){
					LOGGER.info("异常处理");
					this.doException(state,dmFPO,packageName);
					continueFalge = false;
					resultMap.put("result", false);
					resultMap.put("state", state);
					resultMap.put("fileName", packageName);
					continue;
				}
				//拼接执行命令
				LOGGER.info("拼接打包命令");
				for (DmFDetailPO dmFDetailPO : dmfdetails) {
					StringBuffer command = new StringBuffer();
					if(StringUtils.isEmpty(packageName)){
						SimpleDateFormat format = new SimpleDateFormat(DateUtils.STR_DEFAULT_DATE_FORMAT_WITHOUT_SPLIT);  
						packageName = dmFDetailPO.getAbsolutePath().substring(0, dmFDetailPO.getAbsolutePath().lastIndexOf("/")+1)+dmFPO.getDmTaskId()+strategyId+format.format(new Date())+".tar";
						command.append("tar -cPf ").append(packageName).append(" ").append(dmFDetailPO.getAbsolutePath());
						System.out.println(command.toString());
					}else{
						command.append("tar -rPf ").append(packageName).append(" ").append(dmFDetailPO.getAbsolutePath());
					}
					commandMap.put(dmFDetailPO, command.toString());
					LOGGER.info("轨迹明细Id:"+dmFDetailPO.getDetailId()+",命令："+command.toString());
				}
				//连接主机执行命令
				LOGGER.info("连接主机执行命令");
				Map<String,Object> map = this.doCommands(dmFPO,commandMap);
				LOGGER.info("连接主机执行命令,结果:"+(Boolean) map.get("result"));
				if((Boolean) map.get("result")){
					//更新明细数据
					List<Integer> backList = (List<Integer>) map.get("success");
					List<Integer> lossList = (List<Integer>) map.get("loss");
					List<BigDecimal> backSizeList = (List<BigDecimal>) map.get("backSize");
					LOGGER.info("更新明细数据:成功"+backList.size()+"条，失败"+lossList.size()+"条");
					this.updDetails(backList,lossList,backSizeList,packageName,dmFPO);
				}else{
					continueFalge = false;
					resultMap.put("result", false);
					resultMap.put("state", DMSConstant.Status.FALSE.toString());
					resultMap.put("fileName", packageName);
				}
			}else if(time==1){
				continueFalge = false;
				resultMap.put("result", false);
				resultMap.put("state", DMSConstant.Status.SUCCESS.toString());
				resultMap.put("fileName", packageName);
			}else{
				continueFalge = false;
				resultMap.put("result", true);
				resultMap.put("state", DMSConstant.Status.SUCCESS.toString());
				resultMap.put("fileName", packageName);
			}
		}
			
		return resultMap;
	}
	
	/**
	 * 接收资源检测的结果
	 * @return
	 */
	private String isNormal(){
		String state = "";
        TaskNotify notify =  DMSConstant.taskInstList.get(dtsPO.getDmTaskId());
        String code = notify.getStatus();//异常编码
    	
    	 //判断是否接收到异常信号
    	if(DMSConstant.Status.PAUSE.toString().equals(code)||DMSConstant.Status.SYSPAUSE.toString().equals(code)){
    		LOGGER.info("任务Id{0},备份对象={1}暂停操作处理{2}",dtsPO.getDmTaskId(),dtsPO.getCheckObjName(),code);
    		state = code;
    	}else if(DMSConstant.Status.CANCEL.toString().equals(code)){//
    		LOGGER.info("任务Id{0},备份对象={1}取消操作处理{2}",dtsPO.getDmTaskId(),dtsPO.getCheckObjName(),code);
    		state = code;
    	}
		return state;
	}
	
	/**
	 * 对资源监测的结果做出来
	 * @param state
	 * @param dmFPO
	 * @param packageName
	 */
	private void doException(String state,DmFPO dmFPO,String packageName) {
		if(DMSConstant.Status.CANCEL.toString().equals(state)){
			dmfCustomDao.updatedmfStateByInfoId(strategyId,dmFPO.getDmInfoId(),state);
			//dmfCustomDao.updatedmfStateByTrackId(strategyId, dmFPO.getTrackId(), state);
			dmfCustomDao.updateDetailStateByInfoId(strategyId,dmFPO.getDmInfoId(),DMSConstant.Status.CANCELLED.toString());
			LOGGER.info("删除文件："+packageName);
			this.delFile(dmFPO, packageName);
		}
		
	}

	
	/**
	 * 执行打包命令
	 * @param dmFPO
	 * @param commandMap
	 * @return
	 */
	private Map<String,Object> doCommands(DmFPO dmFPO,Map<DmFDetailPO,String> commandMap){
		Map<String,Object> resultMap = new HashMap<String, Object>();
		List<Integer> backList = new ArrayList<Integer>();
		List<Integer> lossList = new ArrayList<Integer>();
		List<BigDecimal> backSizeList = new ArrayList<BigDecimal>();
		String[] commands = new String[commandMap.size()];
		int z=0;
		for (DmFDetailPO dmFDetailPO : commandMap.keySet()) {
			
			backList.add(dmFDetailPO.getDetailId());
			backSizeList.add(dmFDetailPO.getFilesize());
			commands[z] =  commandMap.get(dmFDetailPO);
			z++;
		}
		HostConnInfoVO hostConnInfoVO = baseInfoService.getHostConn(dmFPO.getSrcIp());
		List<HostConnMethodVO> connMethods = hostConnInfoVO.getHostConnMethod();
		for (int i = 0, j = connMethods.size(); i < j; i++) {
			HostConnMethodVO methodVO = connMethods.get(i);
			if (dmFPO.getSrcUser().equals(methodVO.getUserName()) 
					&& DMSConstant.HOST_LINK_SSH.equals(methodVO.getConnMethod())) {
				//组装主机连接信息 HostInfoPOJO
				HostInfoPOJO hostInfoPOJO = 
						new HostInfoPOJO(hostConnInfoVO.getOsType(), hostConnInfoVO.getIp(), 
								methodVO.getUserName(), methodVO.getPassword(), methodVO.getPort(), true);
				List<Object> list = Util.execShellBySSHMethod(hostInfoPOJO, commands);
				for (Object object : list) {
					LOGGER.info(object.toString());
				}
				break;
			}
		}
		/*for (DmFDetailPO dmFDetailPO : commandMap.keySet()) {
			String state = this.ExecuteCommand(dmFPO.getSrcIp(),dmFPO.getSrcUser(), commandMap.get(dmFDetailPO));
			if(DMSConstant.Status.SUCCESS.toString().equals(state)){
				backList.add(dmFDetailPO.getDetailId());
				backSizeList.add(dmFDetailPO.getFilesize());
			}else{
				lossList.add(dmFDetailPO.getDetailId());
			}
		}
		if(backList.size()>0){
			resultMap.put("result",true);
		}else{
			resultMap.put("result",false);
		}*/
		resultMap.put("result",true);
		resultMap.put("success",backList);
		resultMap.put("loss",lossList);
		resultMap.put("backSize",backSizeList);
		return resultMap;
	}
	
	/**
	 * 分批次更新轨迹表
	 * @param backList
	 * @param lossList
	 * @param backSizeList
	 * @param packageName
	 * @param dmFPO
	 */
	private void updDetails(List<Integer> backList,List<Integer> lossList,
			List<BigDecimal>backSizeList,String packageName,DmFPO dmFPO){
		BigDecimal sumSize = BigDecimal.ZERO;
		for (BigDecimal backSize : backSizeList) {
			sumSize.add(backSize);
		}
		dmfCustomDao.updateDetailState(strategyId,backList,DMSConstant.Status.TOCLEANUP.toString());
		dmfCustomDao.updateDetailState(strategyId,lossList,DMSConstant.Status.BACKUPFALSE.toString());
		dmfCustomDao.updateFieSizeAndCountForDMF(strategyId,sumSize,backList.size(),packageName,dmFPO.getTrackId());
		dmfCustomDao.updateFieSizeAndCountForStage(sumSize,backList.size(),dtsPO.getDmInfoId());
	}
	
	/**
	 * 4-2.对文件进行压缩
	 * @param dmFPO
	 * @param fileName
	 * @return
	 */
	private Map<String,Object> compressionFile(DmFPO dmFPO,String fileName){
		Map<String,Object> resultMap = new HashMap<String, Object>();
		String Command = "gzip –r "+fileName;
		int i=0;
		boolean successFlage = false;
		while(i<3){
			i++;
			if(!successFlage){
				String state = this.ExecuteCommand(dmFPO.getSrcIp(),dmFPO.getSrcUser(), Command);
				LOGGER.info("4-2.对文件进行压缩,结果:"+state);
				if(DMSConstant.Status.SUCCESS.toString().equals(state)){
					successFlage = true;
					/*LOGGER.info("删除文件："+fileName);
					this.delFile(dmFPO, fileName);*/
				}
					
			}
		}
		String fileName_new = fileName.trim()+".gz";
		resultMap.put("result", successFlage);
		resultMap.put("fileName", fileName_new);
		return resultMap;
	}

	/**
	 * 4-3.将文件移到目标地址
	 * @param dmFPO
	 * @param filename
	 * @return
	 */
	private Map<String,Object> moveFile(DmFPO dmFPO, String filename){
		Map<String,Object> resultMap = new HashMap<String, Object>();
		String Command = "";
		boolean result = true;
		String tempfilePath = Configuration.getString("tempfilePath");
		String src_filename = filename;
		filename = filename.substring(filename.lastIndexOf("/")+1);
		System.out.println("filename:"+filename);
		if(DMSConstant.DM_BACKUP_TYPE_MV.equals(dmFPO.getDmBackupType())){
			Command = "mv "+src_filename+" "+dmFPO.getTargetPath()+" ";
			String state = this.ExecuteCommand(dmFPO.getSrcIp(),dmFPO.getSrcUser(), Command);
			if(DMSConstant.Status.FALSE.toString().equals(state)){
				result = false;
			}
		}else{
			try{
				//FTP获取源文件 
				HostConnInfoVO hostConnInfoVO = baseInfoService.getHostConn(dmFPO.getSrcIp());
				List<HostConnMethodVO> connMethods = hostConnInfoVO.getHostConnMethod();
				for (int i = 0, j = connMethods.size(); i < j; i++) {
					HostConnMethodVO methodVO = connMethods.get(i);
					if (dmFPO.getSrcUser().equals(methodVO.getUserName())
							&&DMSConstant.HOST_LINK_FTP.equals(methodVO.getConnMethod())) {
						String path = src_filename.substring(0,src_filename.lastIndexOf("/")+1);
						result = SeforgeFtpUtils.downFileByBinary(hostConnInfoVO.getIp(),methodVO.getPort(),
								dmFPO.getSrcUser(),methodVO.getPassword(), path, filename, tempfilePath);
						break;
					}
				}
				
			}catch(Exception e){
				result = false;
			}
			//FTP上传
			if(result){
				try{
					HostConnInfoVO hostConnInfoVO = baseInfoService.getHostConn(dmFPO.getTargetIp());
					List<HostConnMethodVO> connMethods = hostConnInfoVO.getHostConnMethod();
					for (int i = 0, j = connMethods.size(); i < j; i++) {
						HostConnMethodVO methodVO = connMethods.get(i);
						if (dmFPO.getTargetUser().equals(methodVO.getUserName())
								&&DMSConstant.HOST_LINK_FTP.equals(methodVO.getConnMethod())) {
							File tempFile= new File(tempfilePath+filename);
							FileInputStream in=new FileInputStream(tempFile);
							result = SeforgeFtpUtils.uploadFileByBinary(hostConnInfoVO.getIp(),methodVO.getPort(),
									dmFPO.getTargetUser(),methodVO.getPassword(), dmFPO.getTargetPath(), filename, in);
							tempFile.delete();
							break;
						}
					}
					LOGGER.info("删除源主机打的包");
					this.delFile(dmFPO, src_filename);
				}catch(Exception e){
					result = false;
				}
			}

		}
		resultMap.put("result", result);
		return resultMap;
		
	}
	
	/**
	 * 4-4.更新轨迹吧记录
	 * @param backUpState
	 * @param dmFPO
	 * @param filename
	 */
	private void updateData(String backUpState,DmFPO dmFPO,String filename) {
		if(DMSConstant.Status.FALSE.toString().equals(backUpState)){
			dmfCustomDao.updatedmfStateByTrackId(strategyId,dmFPO.getTrackId(),backUpState);
			dmTaskStageDao.updateStateAndEndTimeByPrimaryKey(cleanStagoPO.getDmInfoId(),backUpState);
			dmTaskStageDao.updateStateAndEndTimeByPrimaryKey(dtsPO.getDmInfoId(),backUpState);
			LOGGER.info("删除文件："+filename);
			this.delFile(dmFPO, filename);
			
		}else{
			dmfCustomDao.updatedmfStateByTrackId(strategyId,dmFPO.getTrackId(),DMSConstant.Status.PENDING.toString());
			dmfCustomDao.updateDetailStateByTrackId(strategyId,dmFPO.getTrackId(),DMSConstant.Status.TOCLEANUP.toString());
		}
		
	}
	

	/**
	 * 5.更新备份任务环节表状态
	 * @param backUpState
	 */
	private void updateTaskStageState(String backUpState) {
		String state = backUpState;
		if(DMSConstant.Status.SYSPAUSE.toString().equals(backUpState)
				||DMSConstant.Status.PAUSE.toString().equals(backUpState)){
			state = DMSConstant.Status.PENDING.toString();
		}else if(DMSConstant.Status.CANCEL.toString().equals(backUpState)){
			state = DMSConstant.Status.CANCELLED.toString();
		}else if(DMSConstant.Status.FALSE.toString().equals(backUpState)){
			dmTaskStageDao.updateStateAndEndTimeByPrimaryKey(cleanStagoPO.getDmInfoId(),state);
		}
		dmTaskStageDao.updateStateAndEndTimeByPrimaryKey(dtsPO.getDmInfoId(),state);
		
	}
	
	/**
	 * 删除文件
	 * @param dmFPO
	 * @param fileName
	 */
	private void delFile(DmFPO dmFPO, String fileName){
		String command = "rm -rf "+fileName;
		this.ExecuteCommand(dmFPO.getSrcIp(),dmFPO.getSrcUser(), command);
	}
	
	/**
	 * 连接主机执行命令
	 * @param ip
	 * @param user
	 * @param type
	 * @param command
	 * @return
	 */
	private String ExecuteCommand(String ip, String user, String command){
		String state = DMSConstant.Status.SUCCESS.toString();
		try {
			HostConnInfoVO hostConnInfoVO = baseInfoService.getHostConn(ip);
			List<HostConnMethodVO> connMethods = hostConnInfoVO.getHostConnMethod();
			for (int i = 0, j = connMethods.size(); i < j; i++) {
				HostConnMethodVO methodVO = connMethods.get(i);
				if (user.equals(methodVO.getUserName()) 
						&& DMSConstant.HOST_LINK_SSH.equals(methodVO.getConnMethod())) {
					//组装主机连接信息 HostInfoPOJO
					HostInfoPOJO hostInfoPOJO = 
							new HostInfoPOJO(hostConnInfoVO.getOsType(), hostConnInfoVO.getIp(), 
									methodVO.getUserName(), methodVO.getPassword(), methodVO.getPort(), true);
					List<Object> list = Util.execShellBySSHMethod(hostInfoPOJO, command);
					for (Object object : list) {
						LOGGER.info("命令:"+command+",执行结果:"+object.toString());
					}
					break;
				}
				/*if (user.equals(methodVO.getUserName())) {
					//组装主机连接信息 HostInfoPOJO
					HostInfoPOJO hostInfoPOJO = 
							new HostInfoPOJO(hostConnInfoVO.getOsType(), hostConnInfoVO.getIp(), 
									methodVO.getUserName(), 
									RSAUtils.decryptString(methodVO.getPassword()), 
									methodVO.getPort(), false);
					//根据链接方式指定策略链接主机执行命令 
					if(methodVO.getConnMethod().toLowerCase().equals(DMSConstant.HOST_LINK_SSH)){
						hostResCheck.setCheckStrategy(new SSHCheckStrategy()); 
						hostResCheck.getCheckDataT(hostInfoPOJO, command);
					}else if(methodVO.getConnMethod().toLowerCase().equals(DMSConstant.HOST_LINK_TELNET)){
						hostResCheck.setCheckStrategy(new TelNetCheckStrategy()); 
						hostResCheck.getCheckDataT(hostInfoPOJO, command);
					}
				}*/
			}
			
		} catch (Exception e) {
			e.printStackTrace();
			state = DMSConstant.Status.FALSE.toString();
			LOGGER.error("连接主机执行命令失败："+e.getMessage());
		}
		return state;
	}
    
}
